import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login')
  },
  {
    path: '/',
    // name: 'layout', // 如果父路由有默认子路由，name没有意义
    component: () => import('@/views/Layout'),
    children: [
      {
        path: '',
        name: 'home',
        component: () => import('@/views/Layout/Home')
      },
      {
        path: 'qa',
        name: 'qa',
        component: () => import('@/views/Layout/Qa')
      },
      {
        path: 'videomove',
        name: 'videomove',
        component: () => import('@/views/Layout/VideoMove')
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('@/views/Layout/My')
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/Search')
  },
  {
    path: '/article/:articleId',
    name: 'article',
    props: true, // 路由截取参数,把路由的params参数映射到props中
    component: () => import('@/views/Article')
  },
  {
    path: '/userdata',
    name: 'userdata',
    component: () => import('@/views/UserData')
  }
]
const router = new VueRouter({
  routes
})
export default router
